package com.xiaoxu.spzx.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaoxu.spzx.manager.mapper.BrandMapper;
import com.xiaoxu.spzx.manager.service.BrandService;
import com.xiaoxu.spzx.model.entity.product.Brand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private BrandMapper brandMapper;




    //添加
    @Override
    public void save(Brand brand) {

        brandMapper.save(brand);

    }

    //分页
    @Override
    public PageInfo<Brand> findBrandPage(Integer page, Integer limit) {

        PageHelper.startPage(page,limit);
        List<Brand> brandList = brandMapper.findByPage();//没有条件
        PageInfo<Brand> pageInfo = new PageInfo<>(brandList);
        return pageInfo;
    }


    //修改
    @Override
    public void updateById( Brand brand) {

        brandMapper.update(brand);
    }

    @Override
    public void deleteBrandById(Long id) {
        brandMapper.delete(id);
    }



    //分类品牌----------> 1.查询到所有品牌
    @Override
    public List<Brand> findAll() {
        return  brandMapper.findAll();
    }
}
